/*
 * Copyright (c) 2001 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.p4eclipse.core.api;

/**
  * @version	1.0
  * @author 	<a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class PerforceError 
{
	// severity codes
	
	/** nothing yet */
	public static final int E_EMPTY = 0;
	
	/** something good happened */
	public static final int E_INFO = 1;
	
	/** something not good happened */
	public static final int E_WARN = 2;
	
	/** user did somthing wrong */
	public static final int E_FAILED = 3;
	
	/** system broken -- nothing can continue */
	public static final int E_FATAL = 4;
	
	
	/* DON'T TOUCH THE CONTENT OF THIS VARIABLE */
	private int _nativeHandle;
		
	/**
	  * Call this method to create a new native Error object.
	  */
	public native void init();
	
	/**
	  * Clears the error state.
	  */
	public native void clear();
	
	/**
	  * Checks whether the object indicates any error. 
	  * (severity != E_EMPTY)
	  */
	public native boolean test();
	
	/**
	  * Checks whether the object indicates a fatal error.
	  * (severity == E_FATAL)
	  */
	public native boolean isFatal();
	
	/**
	  * Checks whether the object indicate a warning.
	  * (severity == E_WARN)
	  */
	public native boolean isWarning();
	
	/**
	  * Returns the error's severity.
	  */
	public native int getSeverity();
	
	/**
	  * Return the error's generic error code.
	  */ 
	public native int getGeneric();
	
	/**
	  * Formats the error into a String.
	  */
	public native String fmt();
	
	/**
	  * Reports the error to the console.
	  */
	public native void report();
		
	/**
	  * Call this method to destroy the native Error object.
	  */
	public native void dispose();

	public String toString()
	{
		return "S" + getSeverity() + " G" + getGeneric() + " " + fmt();
	}
}

